/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.sequence.ui.properties.tabbed;

import org.eclipse.uml2.uml.Interaction;
import org.eclipse.uml2.uml.InteractionUse;
import org.eclipse.uml2.uml.NamedElement;

import com.cea.papyrus.core.tabbedproperties.AbstractSelectionElementSection;
import com.cea.papyrus.diagram.sequence.ui.filters.InteractionFilter;

/**
 * Property view section to set the refersTo property of a {@link InteractionUse}
 * 
 */
public class InteractionUseRefersToSection extends AbstractSelectionElementSection {
	
	public InteractionUseRefersToSection() {
		super("Refers to:", new InteractionFilter());
	}

	@Override
	public NamedElement getReferencedElementToDisplay() {
		return ((InteractionUse) umlElement).getRefersTo();
	}

	@Override
	public void removeReferencedElement() {
		((InteractionUse) getElement()).setRefersTo(null);	
	}

	@Override
	public void setReferencedElement(NamedElement element) {
		if (element instanceof Interaction) {
			Interaction interaction = (Interaction) element; 
			if (interaction != null) {				
				((InteractionUse) getElement()).setRefersTo(interaction);
			}
		}
	}
}

